namespace Delphi.Mimir.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddCorporateAction : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "fin.eod_corporate_actions",
                c => new
                    {
                        coa_id = c.Int(nullable: false, identity: true),
                        coa_sym_id = c.Int(nullable: false),
                        coa_cat_id = c.Int(nullable: false),
                        coa_action_dt = c.DateTime(nullable: false),
                        coa_amount = c.Decimal(nullable: false, precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.coa_id)
                .ForeignKey("fin.com_categories", t => t.coa_cat_id, cascadeDelete: true)
                .ForeignKey("fin.eod_symbols", t => t.coa_sym_id, cascadeDelete: true)
                .Index(t => new { t.coa_sym_id, t.coa_action_dt, t.coa_cat_id }, unique: true, name: "IX_COA");
            
            CreateTable(
                "raw.eod_corporate_actions",
                c => new
                    {
                        coa_id = c.Int(nullable: false, identity: true),
                        coa_sym_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        coa_exc_cd = c.String(nullable: false, maxLength: 25, unicode: false),
                        coa_action_desc = c.String(nullable: false, maxLength: 250, unicode: false),
                        coa_action_dt = c.DateTime(nullable: false),
                        coa_amount = c.Decimal(nullable: false, precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.coa_id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("fin.eod_corporate_actions", "coa_sym_id", "fin.eod_symbols");
            DropForeignKey("fin.eod_corporate_actions", "coa_cat_id", "fin.com_categories");
            DropIndex("fin.eod_corporate_actions", "IX_COA");
            DropTable("raw.eod_corporate_actions");
            DropTable("fin.eod_corporate_actions");
        }
    }
}
